package pacman.entries.pacman.ml.behaviors;

import pacman.game.Constants.DM;
import pacman.game.Constants.GHOST;
import pacman.game.Constants.MOVE;
import pacman.game.Game;

public class RunAwayFromGhostsBehavior extends Behavior {

	@Override
	public MOVE decide(Game game) {
		int current=game.getPacmanCurrentNodeIndex();
		GHOST ghost = GHOST.BLINKY;
		int distance = game.getShortestPathDistance(current,game.getGhostCurrentNodeIndex(GHOST.BLINKY));
		for(GHOST aGhost : GHOST.values()) {
			int thisDistance = game.getShortestPathDistance(current,game.getGhostCurrentNodeIndex(aGhost));
			if (thisDistance < distance) {
				distance = thisDistance;
				ghost = aGhost;
			}
		}
		
		return game.getNextMoveAwayFromTarget(game.getPacmanCurrentNodeIndex(),game.getGhostCurrentNodeIndex(ghost),DM.PATH);
	}
	
}